﻿using FactoryClsssLib.Examples;
using FactoryClsssLib.Examples2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;

namespace FactoryClsssLib.Factory
{
    /// <summary>
    /// 工厂选择器(工厂模式)
    /// </summary>
    public class FactoryProducer
    {
        public static Dictionary<string, Type> keyValuePairs
        {
            get
            {
                return new Dictionary<string, Type>() {
                    { "ShapeFactory",typeof(ShapeFactory)},
                    { "ColorFactory",typeof(ColorFactory)},
                    { "ShapeFactory",typeof(ShapeFactory)}
                };
            }
        }
        public static object getFactory(String choice)
        {
            // IAbstractFactory<T> abstractFactory = new T
            if (choice.Equals("SHAPE"))
            {
                IAbstractFactory<IShape> abstractFactory = new ShapeFactory();
                return abstractFactory;
            }
            else if (choice.Equals("COLOR"))
            {
                IAbstractFactory<IColor> abstractFactory = new ColorFactory();
                return abstractFactory;
            }
            else if (choice.Equals("CODE"))
            {
                IAbstractFactory<IShape> abstractFactory = new ShapeFactory();
                return abstractFactory;
            }
            return null;
        }
    }
}
